package savesystem;

import exploration.Exploration;
import graphinterface.MouseDetector;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;

public class MenuSecondaire extends BasicGameState{
	
	public static final int ID = 2;
	
	private MouseDetector sauvegarde1;
	private MouseDetector sauvegarde2;
	private MouseDetector sauvegarde3;
	
	private Color[] couleurBouton = {Color.white, Color.gray, Color.red};

	public void init(GameContainer gc, StateBasedGame game) throws SlickException {
		sauvegarde1 = new MouseDetector(new Rectangle(gc.getWidth()/2 - 40, gc.getHeight()/2 + 50, 80, 20), 
				couleurBouton, "save 1");
		sauvegarde2 = new MouseDetector(new Rectangle(gc.getWidth()/2 - 40, gc.getHeight()/2 + 100, 80, 20), 
				couleurBouton, "save 2");
		sauvegarde3 = new MouseDetector(new Rectangle(gc.getWidth()/2 - 40, gc.getHeight()/2 + 150, 80, 20), 
				couleurBouton, "save 3");
	}

	public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
		sauvegarde1.draw(g);
		sauvegarde2.draw(g);
		sauvegarde3.draw(g);
	}

	public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
		sauvegarde1.update(gc, 0);
		sauvegarde2.update(gc, 0);
		sauvegarde3.update(gc, 0);
		
		if (sauvegarde1.isPushed()){
			PlayerStat.saveName = "save1";
			game.enterState(Exploration.ID, new FadeOutTransition(), new FadeInTransition());
			sauvegarde1.resetPushed();
		}
		if (sauvegarde2.isPushed()){
			PlayerStat.saveName = "save2";
			game.enterState(Exploration.ID, new FadeOutTransition(), new FadeInTransition());
			sauvegarde2.resetPushed();
		}
		if (sauvegarde3.isPushed()){
			PlayerStat.saveName = "save3";
			game.enterState(Exploration.ID, new FadeOutTransition(), new FadeInTransition());
			sauvegarde3.resetPushed();
		}
	}

	public int getID() {
		return ID;
	}

}
